/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bgu.ppm.sim.impl.mas;

import bgu.ppm.sim.api.mas.MailBox;
import bgu.ppm.sim.api.mas.Message;
import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 *
 * @author User
 */
public class SimpleMailbox implements MailBox {

    ConcurrentLinkedQueue<Message> messages = new ConcurrentLinkedQueue<>();

    @Override
    public Message popMessage() {
        return messages.poll();
    }

    @Override
    public boolean hasMessages() {
        return !messages.isEmpty();
    }

    @Override
    public Iterator<Message> iterator() {
        return messages.iterator();
    }

    public void pushMessage(Message m) {
        messages.add(m);
    }
}
